package com.example.administrator.exkotlin.jetpack.room.dao

import androidx.room.*
import com.example.administrator.exkotlin.jetpack.room.entity.User

/**
 * Author by lp,on 2020/11/19/019,11:44.
 */
@Dao
interface UserDao {
    @Insert
    fun inserUser(user: User): Long

    @Update
    fun updateUser(newUser: User)

    @Query("select * from User")
    fun loadAllUSers(): List<User>

    @Delete
    fun deleteUser(user: User)

    @Query("delete from User where lastName=:lastName")
    fun deleteUserByLastName(lastName: String): Int

    @Query("select * from User limit 1 offset (select count(*) - 1 from User)")
    fun findLastUser():User

    @Query("select * from User limit 1 ")
    fun findFirstUser():User

}